<include file="../header"/>
<div class="wrapper">
    <div class="main">

        <div class="header text-center font-16">
            指派
            <div class="iconfont icon-zuo go_index"></div>
        </div>

        <div class="history-list">
            <div class="repair-list">
                <div class="width-82 font-12">报修地址：</div>
                <span>{BEESCRM:$data.community_name}{BEESCRM:$data.building_name}{BEESCRM:$data.floor_name}{BEESCRM:$data.room_name}</span>
            </div>
            <div class="flex-between2 repair-list">
                <div class="width-80">
                    <p>
                        <span class="width-82 font-12">报修项目：</span>
                        <if condition="$data.type eq 2">
                            <span>公共报修 {BEESCRM:$data.public_name}</span>
                            <else/>
                            <span>{BEESCRM:$data.project_name}/{BEESCRM:$data.project_child_name}</span>
                        </if>
                    </p>
                    <p class="margin-t4">
                        <span class="width-82 font-12">描述：</span>
                        <span>{BEESCRM:$data.content}</span>
                    </p>
                </div>
                <div class="images">
                    <!-- <a href="{BEESCRM:$data.image}"><img src="{BEESCRM:$data.image}" alt=""></a> -->
                    <a href="javascript:;"><img class="js_images" src="{BEESCRM:$data.image}" alt=""></a>
                </div>
            </div>


            <div class="repair-list">
                <!--挂起状态-->
                <if condition="$data.status eq 4 AND $data.hang_up eq 1">
                    <p>
                        <span class="width-82">挂单描述：</span><span class="font-16">{BEESCRM:$data.hang_remark}</span>
                    </p>
                </if>
                <if condition="$data.status egt 5">
                    <p class="margin-t4">
                        <span class="width-82 font-12">维修数量：</span>
                        <span>{BEESCRM:$data.goods_num}</span>
                    </p>
                </if>
                <p>
                    <span class="width-82 font-12">报修费用：</span>
                    <span class="money">
                        <span class="iconfont icon-qian01 font-12"></span>{BEESCRM:$data.order_amount}
                    </span>
                </p>
            </div>

            <!--<if condition="$data.status egt 5">
                <div class="flex-between repair-list">
                    <div>
                        <p class="margin-t4">
                            <span class="width-82 font-12">维修图片：</span>
                        </p>
                    </div>
                    <div class="images">
                        <img class="js_images" src="{BEESCRM:$data.finish_image}" alt="">
                    </div>
                </div>
            </if>-->
        </div>

        <if condition="$data.is_comment eq 0 and $data.status neq 5">
            <div class="history-list margin-b12">
                <div class="tab flex-between" id="assign_type">
                    <div class="tab-list text-center"><span class="actived" data-type="0">指派给</span></div>
                    <div class="tab-list text-center"><span data-type="1">交接给</span></div>
                </div>
                <div>
                    <div class="js-people show" id="assign_worker">
                        <div class="Swiper-container ">
                            <div class="js_width clearfix">
                                <volist name="worker" id="vo">

                                    <div class="Swiper-slide pull-left">
                                        <div class="icon-tx">
                                            <if condition="$vo['avatar'] eq ''">
                                                <img src="/assets/repaireast/images/touxiang.png" alt="">
                                                <else/>
                                                <img src="{BEESCRM:$vo.avatar}" alt="">
                                            </if>
                                            <if condition="$vo['is_choose'] eq 1">
                                                <div class="iconfont icon-xuanze">
                                                    <input type="hidden" class="user_id" value="{BEESCRM:$vo.user_id}">
                                                </div>
                                                <else/>
                                                <div class="iconfont">
                                                    <input type="hidden" class="user_id" value="{BEESCRM:$vo.user_id}">
                                                </div>
                                            </if>
                                        </div>
                                        <p class="text-center p-name">{BEESCRM:$vo.real_name}</p>
                                    </div>

                                </volist>
                            </div>
                        </div>
                    </div>
                    <div class="js-people hide" id="assign_manager">
                        <div class="Swiper-container2 ">
                            <div class="js_width2 clearfix">
                                <volist name="manager" id="vo">
                                    <div class="Swiper-slide2 pull-left">
                                        <div class="icon-tx">
                                            <if condition="$vo['avatar'] eq ''">
                                                <img src="/assets/repaireast/images/touxiang.png" alt="">
                                                <else/>
                                                <img src="{BEESCRM:$vo.avatar}" alt="">
                                            </if>
                                            <if condition="$vo['user_id'] eq $assignManager">
                                                <div class="iconfont icon-xuanze">
                                                    <input type="hidden" class="user_id" value="{BEESCRM:$vo.user_id}">
                                                </div>
                                                <else/>
                                                <div class="iconfont">
                                                    <input type="hidden" class="user_id" value="{BEESCRM:$vo.user_id}">
                                                </div>
                                            </if>
                                        </div>
                                        <p class="text-center">{BEESCRM:$vo.real_name}</p>
                                    </div>
                                </volist>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <elseif condition="$data.is_comment eq 1"/>
            <div class="history-list evaluate-box margin-b12">
                <div class="evaluate">
                    <span class="width-82">服务态度：</span>
                    <for start="1" end="6" name="i">
                        <if condition="$data.service_star egt $i">
                            <span class="iconfont xingxing icon-xingxing"></span>&nbsp;&nbsp;
                            <else/>
                            <span class="iconfont icon-xingxing"></span>&nbsp;&nbsp;
                        </if>
                    </for>
                </div>
                <div class="evaluate">
                    <span class="width-82">维修质量：</span>
                    <for start="1" end="6" name="i">
                        <if condition="$data.quality_star egt $i">
                            <span class="iconfont xingxing icon-xingxing"></span>&nbsp;&nbsp;
                            <else/>
                            <span class="iconfont icon-xingxing"></span>&nbsp;&nbsp;
                        </if>
                    </for>
                </div>
                <div class="evaluate">
                    <span class="width-82">响应速度：</span>
                    <for start="1" end="6" name="i">
                        <if condition="$data.answer_star egt $i">
                            <span class="iconfont xingxing icon-xingxing"></span>&nbsp;&nbsp;
                            <else/>
                            <span class="iconfont icon-xingxing"></span>&nbsp;&nbsp;
                        </if>
                    </for>
                </div>
                <div class="evaluate">
                    <span class="width-82">描述：</span>
                    <span class="font-16">{BEESCRM:$data.comment}</span>
                </div>
            </div>
        </if>
    </div>
    <if condition="$data.status egt 1 AND $data.status neq 5">
        <a href="#" class="btn add text-center" id="assign_submit">确定指派</a>
    </if>
    <input type="hidden" id="order_id" value="{BEESCRM:$data.order_id}">

    <div class="pop-box hide pop-tab">
        <div class="table-cell">
            <div class="pop-images">
                <img class="js_pop-img" src="" alt="">
                <div class="pop-close iconfont  icon-cheng1">
                </div>

            </div>
        </div>
    </div>
</div>
<script src="/assets/repaireast/js/layer.js"></script>
<script src="/assets/repaireast/js/public.js"></script>
<script>
    $(function () {
        // 如果已经指派过了则不允许修改
        var status = "{BEESCRM:$data.status}";
        $('.icon-tx').each(function () {
            if (status >= 2 && $(this).find('.iconfont').hasClass('icon-xuanze')) {
                $(this).find('.iconfont').addClass('icon-sign');
            }
        });

        $('.icon-tx').click(function () {
            if ($(this).find('.iconfont').hasClass('icon-sign')) {
                return false;
            }
            else if ($(this).find('.iconfont').hasClass('icon-xuanze')) {
                $(this).find('.iconfont').removeClass('icon-xuanze');
            } else {
                $(this).find('.iconfont').addClass('icon-xuanze');
            }
        });

        $('.tab').on('click', '.tab-list', function () {
            var idx = $(this).index();
            $('.js-people').eq(idx).removeClass('hide').addClass('show').siblings().removeClass('show').addClass('hide');
            $(this).children().addClass('actived').parents().siblings().children().removeClass('actived');
        });

        $('#assign_submit').click(function () {
            var can_submit = 1;
            var type = $('#assign_type .actived').data('type');//0=指派维修工 1=交接维修主管

            var user_id = '';
            if (type == 1) {
                var i = 0;
                $('#assign_manager .icon-xuanze .user_id').each(function () {
                    i++;
                });
                if (i > 1) {
                    fm.alert('只能交接给一名维修主管!');
                    can_submit = 0;
                }
                user_id = $('#assign_manager .icon-xuanze .user_id').val();
                var url = '/Repaireast/RepaireastManager/assignManager';
            } else {
                $('#assign_worker .icon-xuanze .user_id').each(function () {
                    user_id += $(this).val() + ',';
                });
                var url = '/Repaireast/RepaireastManager/assignWorker';
            }

            if (user_id == '') {
                fm.alert('请选择人员!');
                can_submit = 0;
            }

            if (can_submit == 1) {
                $.ajax({
                    type: 'post',
                    url: url,
                    dataType: 'json',
                    data: {
                        'user_id': user_id, 'order_id': $('#order_id').val()
                    },
                    success: function (data) {
                        fm.alert(data.message);
                        setTimeout(function () {
                            window.location.href = '/Repaireast/Repaireast/index/status/2';
                        }, 2000);
                    },
                    error: function () {
                        fm.alert('请选择其他的维修工');
                    }
                });
            }


        });
    })

    //js_width的宽度
    var Swiperslide_width = $('.Swiper-slide').outerWidth(true);
    var Swiperslide_length = $('.Swiper-slide').length;
    $('.js_width').css('width', Swiperslide_width * Swiperslide_length);


    var Swiperslide2_width = $('.Swiper-slide2').outerWidth(true);
    var Swiperslide2_length = $('.Swiper-slide2').length;
    $('.js_width2').css('width', Swiperslide2_width * Swiperslide2_length);


    $('.js_images').click(function () {
        var src = $(this).attr('src');
        $('.pop-box').removeClass('hide');
        $('.js_pop-img').attr('src', src);
    })
    $('.pop-close').click(function () {
        $('.pop-box').addClass('hide');
    })

</script>
<include file="../footer"/>